<?
	
	include 'headermenu.php';
	//include_once 'functions_oana.php';
	
	$selected = "";
    $rand = "";
?>
		<div id="doc" class="yui-t7"> 
		<div id="bd" role="main"> 
		<div class="yui-gc"> 
		<link rel="stylesheet" href="yui.css" type="text/css">
	    <div class="yui-u first"> 
	    <!-- YOUR DATA GOES HERE --> 
		 
		 <form action="" method="post">
		
					Company Furnizor:
		
				<select name="selectId1" id="selectId1" style="width:150px;" onchange="if(this.value > -1) {this.form.submit();}">
					<?php
						$dbh = dbConn();
						
						echo "<option value=\"-1\">-- Select Item --</option>\n";
			
						$instructiune="SELECT id, name FROM companies;";
						
						$interogare = mysql_query($instructiune);
						
						while($rand = mysql_fetch_array($interogare))
						{   $gigel = "selectId1";
							if($_POST["selectId1"] == $rand['id'])
							{
								$selected="selected";
							}
							else
							{
								$selected="";
							}
							
							echo("<option ".$selected." value='".$rand['id']."'> ".$rand['name']." </option>  \n");
						}			
							if(ISSET($_POST["selectId1"]))
				{
					$id1 = $_POST['selectId1'];
					$query1 = "SELECT * FROM companies WHERE ID=".$id1;
		
		$result1 = mysql_query($query1);

		while ($row1 = mysql_fetch_assoc($result1))
		{
			$id1 = $row1['id'];
			$name1 = $row1['name'];
			$cui1 = $row1['cui'];
			$j1 = $row1['j'];
			$street1 = $row1['street'];
			$nr1 = $row1['nr'];
			$building1 = $row1['building'];
			$floor1 = $row1['floor'];
			$city1= $row1['city'];
			$county1 = $row1['county'];
			$country1 = $row1['country'];
			$postal_code1 = $row1['postal_code'];
			$bank1 = $row1['bank'];
			$bank_account1 = $row1['bank_account'];
		}
				}
					?>
				</select>	
             
			 
				Company Client:
		
				<select name="selectId2" id="selectId2" align="right" style="width:150px;" onchange="if(this.value > -1) {this.form.submit();}">
					<?php
						$dbh = dbConn();
						
						echo "<option value=\"-1\">-- Select Item --</option>\n";
			
						$instructiune="SELECT id, name FROM companies;";
						
						$interogare = mysql_query($instructiune);
						
						while($rand = mysql_fetch_array($interogare))
						{  
							if($_POST["selectId2"] == $rand['id'])
							{
								$selected="selected";
							}
							else
							{
								$selected="";
							}
							
							echo("<option ".$selected." value='".$rand['id']."'> ".$rand['name']." </option>  \n");
						}			
							if(ISSET($_POST["selectId2"]))
				{
					$id2 = $_POST['selectId2'];
					$query2 = "SELECT * FROM companies WHERE ID=".$id2;
		
		$result2 = mysql_query($query2);

		while ($row2 = mysql_fetch_assoc($result2))
		{
			$id2 = $row2['id'];
			$name2 = $row2['name'];
			$cui2 = $row2['cui'];
			$j2 = $row2['j'];
			$street2 = $row2['street'];
			$nr2 = $row2['nr'];
			$building2 = $row2['building'];
			$floor2 = $row2['floor'];
			$city2 = $row2['city'];
			$county2 = $row2['county'];
			$country2 = $row2['country'];
			$postal_code2 = $row2['postal_code'];
			$bank2 = $row2['bank'];
			$bank_account2 = $row2['bank_account'];
		}
				}
					?>
				</select>
			
			
		</form>	
		<table width="100%" >
	<tr>
		<td width="15%">
			<?php
			    if(ISSET($_POST["selectId1"]))
				{
				echo "<img src=\"afisare.php?id=".$_POST["selectId1"]."\" style=\"width:125px; height:75px;\"/>";
				}
				
			?>
		</td>
		
		<td align="center" width="70%">
		Project
		</td>
		<td width="15%">
			<?php
			    if(ISSET($_POST["selectId2"]))
				{
				echo "<img src=\"afisare.php?id=".$_POST["selectId2"]."\" style=\"width:125px; height:75px;\"/>";
				}
				
			?>
		</td>
		
	</tr>
	<tr>
		<td width="15%" >
		<?php
				echo $name1."<br>";
				echo $cui1."<br>";
				echo $j1."<br>";
				echo $street1."<br>";
				echo $nr1."<br>";
				echo $building1."<br>";
				echo $floor1."<br>";
				echo $city1."<br>";
				echo $county1."<br>";
				echo $country1."<br>";
				echo $postal_code1."<br>";
				echo $bank1."<br>";
				echo $bank_account1."<br>";
		?>
		</td>
		<td width="70%" align="center">
		Type document
		</td>
		<td width="15%">
		<?php
				echo $name2."<br>";
				echo $cui2."<br>";
				echo $j2."<br>";
				echo $street2."<br>";
				echo $nr2."<br>";
				echo $building2."<br>";
				echo $floor2."<br>";
				echo $city2."<br>";
				echo $county2."<br>";
				echo $country2."<br>";
				echo $postal_code2."<br>";
				echo $bank2."<br>";
				echo $bank_account2."<br>";
		?>
				</td>
		
	</tr>
</table>
		
	        </div> 
			
	    <div class="yui-u"> 
	    <!-- YOUR DATA GOES HERE --> 
		
		

	        </div> 
	</div> 
	 
	    </div> 
	   <div id="ft" role="contentinfo"><p>Footer</p></div> 
	</div> 

	<script type="text/javascript">
		function createImg(aElement)
		{
			tdElement = document.getElementById("tdId");
			
			tdElement.innerHTML	 = "<img src=\""+aElement.href+"\" style=\"width:100px; height:75px;\"/>";			
		}
	</script>
	
</body>
</html>
